package leetcode.easy.checkdistances;

import java.util.HashMap;
import java.util.Map;

public class Solution {
    public boolean checkDistances(String s, int[] distance) {
        Map<Character, Integer> distanceMap = new HashMap<>();
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (distanceMap.get(c) == null) {
                distanceMap.put(c, i);
            } else {
                int gap = i - distanceMap.get(c) - 1;
                if (distance[c - 97] != gap) {
                    return false;
                }
            }
        }
        return true;
    }

    public static void main(String[] args) {
        int[] distance = new int[26];
        distance[0] = 1;
        distance[1] = 3;
        System.out.println(new Solution().checkDistances("abaccb", distance));
    }
}
